﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace VisaValeCheck
{
    [Serializable()]
    public sealed class Compra
    {
        [XmlAttribute()]
        public double Valor { get; set; }
        [XmlAttribute()]
        public DateTime Data { get; set; }
        [XmlAttribute()]
        public string Local { get; set; }

        public Compra()
        {
        }

        public Compra(double valor, DateTime data, string local)
        {
            Valor = valor;
            Data = data;
            Local = local;
        }

        public override bool Equals(object obj)
        {
            return (obj is Compra) && ((Compra)obj == this);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public static bool operator ==(Compra a, Compra b)
        {
            return ((object)a != null && (object)b != null && a.Data == b.Data && (a.Local == b.Local || Apoio.Jaccard(a.Local, b.Local).Proximidade >= 0.75) && a.Valor == b.Valor) ||
                ((object)a == null && (object)b == null);
        }

        public static bool operator !=(Compra a, Compra b)
        {
            return (((object)a != null && (object)b == null) || ((object)a == null && (object)b != null)) ||
                ((object)a != null && (object)b != null && (a.Data != b.Data || (a.Local != b.Local && Apoio.Jaccard(a.Local, b.Local).Distancia > 0.50) || a.Valor != b.Valor));
        }
    }
}
